package com.amz.analyzer.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * <p>
 * 描述: swagger API文档配置
 * </p>
 *
 * @author Freddy
 * @version 1.0
 * @since 2020/7/12 13:58
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {

    @Bean
    public Docket createDocket() {
        return new Docket(DocumentationType.SWAGGER_2)
                //进入swagger-ui的信息
                .apiInfo(apiInfo())
                .select()
                //暴露所有controller类的所在的包路径
                .apis(RequestHandlerSelectors.basePackage("com.amz.analyzer"))
                .paths(PathSelectors.any())
                .build()
                .enable(true);
    }

    //进入swagger-ui的信息
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                //该项目的名字
                .title("服务API")
                //该项目的描述
                .description("各种服务；")
                .version("1.0")
                .build();
    }

}
